<%-- 
    Document   : header
    Created on : 25 avr. 2011, 15:39:44
    Author     : simon
--%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%-- On applique le langage choisie ou on set a FR par default --%>
<c:choose>
    <c:when test="${!empty language}">
        <fmt:setLocale value="${language}" scope="session" />
    </c:when>
    <c:otherwise>
        <fmt:setLocale value="fr" scope="session" />
    </c:otherwise>
</c:choose>


<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="/ecom-web/css/style.css">
        <link rel="shortcut icon" href="/ecom-web/img/favicon.ico">

        <script src="/ecom-web/js/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="/ecom-web/js/jquery.easing.min.js"></script>
        <script type="text/javascript" src="/ecom-web/js/jquery.lavalamp.min.js"></script>
        <script type="text/javascript">
            $(function() {

                $("div.panel_button").click(function(){
                    $("div#panel").animate({
                        height: "350px"
                    })
                    .animate({
                        height: "300px"
                    }, "fast");
                    $("div.panel_button").toggle();

                });

                $("div#hide_button").click(function(){
                    $("div#panel").animate({
                        height: "0px"
                    }, "fast");


                });

                $(".lava").lavaLamp({
                    fx: "backout",
                    speed: 700,
                    click: function(event, menuItem) {
                        return true;
                    }
                });
            });
        </script>
    </head>

    <body>
        <div id="wrapper">


            <c:choose>
                <c:when test="${customer != null}">
                    <div id="accountLabel" class="smallText">
                        Bonjour ${customer.firstName} - <span class="bubble rounded"><a href="<c:url value='account'/>" title="account">Mon compte</a></span>
                    </div>
                </c:when>
                <c:otherwise>
                    <div id="toppanel">
                        <div id="panel">
                            <h1>Login form</h1>
                            <div class="border" id="login">
                                <form action="<c:url value='login'/>" method="post">
                                    <p>Username:
                                        <input type="text" size="15" name="email" id="username" />
                                        <br />
                                        Password:
                                        <input type="password" size="15" name="password" id="password" />
                                        <br />
                                        <input type="submit" accesskey="l" id="login_btn" name="login" value="Login" />
                                    </p>
                                </form>
                            </div>
                        </div>

                        <div class="panel_button" style="display: visible;"><img src="icon/expand.png"  alt="expand"/> <a href="#">Login Here</a> </div>
                        <div class="panel_button" id="hide_button" style="display: none;"><img src="icon/collapse.png" alt="collapse" /> <a href="#">Hide</a> </div>
                    </div>
                </c:otherwise>
            </c:choose>


            <div id="header">

                <div id="widget">

                    <%-- Section du panier --%>
                    <div id="cart">
                        <img src="/ecom-web/icon/bag.png" alt="shopping bag icon" id="bagImage" class="icon"/>

                        <%-- Si la propriete n'existe pas, ou que le nombre d'item est de 0, output '0', sinon output 'numberOfItems' --%>
                        <span class="marginLeft">
                            <c:choose>
                                <c:when test="${cartNbItems == null}">
                                    0
                                </c:when>
                                <c:otherwise>
                                    ${cartNbItems}
                                </c:otherwise>
                            </c:choose>
                            item
                        </span>

                        <c:if test="${cartNbItems ne null && cartNbItems != 0 &&
                                      !fn:contains(pageContext.request.servletPath,'/cart') &&
                                      requestScope['javax.servlet.forward.servlet_path'] ne '/cart'}">

                              <span class="bubble rounded"><a href="<c:url value='/cart'/>">
                                      <fmt:message key="cart" />
                                  </a></span>
                              </c:if>

                    </div>
                    <div>
                        <c:choose>
                            <c:when test="${empty sessionScope['javax.servlet.jsp.jstl.fmt.locale.session']}">
                                <c:choose>
                                    <c:when test="${pageContext.request.locale.language ne 'en'}">
                                        français
                                    </c:when>
                                    <c:otherwise>
                                        <c:url var="url" value="chooseLanguage">
                                            <c:param name="language" value="en"/>
                                        </c:url>
                                        <span class="rounded bubble"><a href="${url}">français</a></span>
                                    </c:otherwise>
                                </c:choose> |

                                <c:choose>
                                    <c:when test="${pageContext.request.locale.language eq 'en'}">
                                        english
                                    </c:when>
                                    <c:otherwise>
                                        <c:url var="url" value="chooseLanguage">
                                            <c:param name="language" value="en"/>
                                        </c:url>
                                        <span class="rounded bubble"><a href="${url}">english</a></span>
                                    </c:otherwise>
                                </c:choose>
                            </c:when>

                            <%-- Otherwise, render widget according to the set locale --%>
                            <c:otherwise>
                                <c:choose>
                                    <c:when test="${sessionScope['javax.servlet.jsp.jstl.fmt.locale.session'] ne 'en'}">
                                        français
                                    </c:when>
                                    <c:otherwise>
                                        <c:url var="url" value="chooseLanguage">
                                            <c:param name="language" value="fr"/>
                                        </c:url>
                                        <span class="rounded bubble"><a href="${url}">français</a></span>
                                    </c:otherwise>
                                </c:choose> |

                                <c:choose>
                                    <c:when test="${sessionScope['javax.servlet.jsp.jstl.fmt.locale.session'] eq 'en'}">
                                        english
                                    </c:when>
                                    <c:otherwise>
                                        <c:url var="url" value="chooseLanguage">
                                            <c:param name="language" value="en"/>
                                        </c:url>
                                        <span class="rounded bubble"><a href="${url}">english</a></span>
                                    </c:otherwise>
                                </c:choose>
                            </c:otherwise>
                        </c:choose>
                    </div>

                </div>

                <div id="logo">Winery<br /><span class="normal">l'art d'acheter le vin!</span></div>


                <div id="menu">
                    <ul class="lava">
                        <li class=""><a href="/ecom-web" title=""><fmt:message key="home" /></a></li>
                        <li class="<c:if test="${requestScope['javax.servlet.forward.servlet_path'] == '/products' ||
                                                 requestScope['javax.servlet.forward.servlet_path'] == '/addToCart'}">current</c:if>"><a href="<c:url value='/products' />" title="Liste des produits"><fmt:message key="vins" /></a></li>
                        <li class="<c:if test="${requestScope['javax.servlet.forward.servlet_path'] == '/store'}">current</c:if>"><a href="<c:url value='/store' />" title="Liste des magasins"><fmt:message key="stores" /></a></li>
                        <li class="<c:if test="${requestScope['javax.servlet.forward.servlet_path'] == '/category'}">current</c:if>"><a href="<c:url value='/category' />" title="Produits par category"><fmt:message key="byRegion" /></a></li>
                    </ul>
                </div> <%-- Menu dans les autres pages que l'index --%>

            </div>

            <c:if test="${infoMessage != null}">
                <div id="infoMessage" class="panelInfo">
                    <div>Message : <c:out value="${infoMessage}"></c:out></div>
                </div>
            </c:if>

            <c:if test="${errorMessage != null}">
                <div id="errorMessage" class="panelInfo">
                    <div>Erreur : <c:out value="${errorMessage}"></c:out></div>
                </div>
            </c:if>

